/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hugoo.core;

import com.hugoo.core.util.TL;
import com.hugoo.form.xo.XForm;
import com.hugoo.form.xo.XHandle;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author Hugoo
 */
public class UnAuthz {

    static final Set<String> url = new HashSet();

    public static synchronized void putUri(String uri) {
        url.add(uri);
    }

    public static synchronized void putXHandle(XForm xform, XHandle xhandle) {
        String xhId = xhandle.getId(), xfId = xform.getList();
        if (TL.isNotEmpty(xhId, xfId) && xhId.equalsIgnoreCase(xfId)) {
            url.add(xform.getId() + ".json");
            url.add(xform.getId() + "-" + xhandle.getId() + ".json");
        }
        url.add(xform.getId() + "-" + xhandle.getId() + ".form");
    }

    public static boolean authz(String uri) {
        return url.contains(uri);
    }
    public static String authuri(){
        return url.toString();
    }
}
